﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MovieDB.Web.Html
{
    public static class HtmlUtilities
    {
        public static string WriteValue(this HtmlHelper html, string value, string defaultIfEmpty)
        {
            string result;
            if (string.IsNullOrEmpty(value))
            {
                result = HttpUtility.HtmlEncode(defaultIfEmpty);
            }
            else
            {
                result = HttpUtility.HtmlEncode(value);
            }

            return result;
        }

        public static string WriteValue(this HtmlHelper html, string value)
        {
            return WriteValue(html, value, string.Empty);
        }
    }
}